﻿/*公共js库*/

/*信息提示公共JS方法*/
/*需引入Jquery与artDialog4.1.5插件*/
var Popup = {
    /*
    /// <summary>
    /// 成功提示
    /// </summary>
    /// <param name="msg">提示消息</param>
    /// <param name="callback">回调函数</param>
    */
    Success: function (msg, callback) {
        $.dialog({
            content: msg,
            icon: 'success',
            ok: callback || null
        });
    },
    /*
    /// <summary>
    /// 错误提示
    /// </summary>
    /// <param name="msg">提示消息</param>
    /// <param name="callback">回调函数</param>
    */
    Error: function (msg, callback) {
        $.dialog({
            content: msg,
            icon: 'error',
            ok: callback || null
        });
    },
    /*
    /// <summary>
    /// 友好提示信息
    /// </summary>
    /// <param name="msg">提示消息</param>
    /// <param name="callback">回调函数</param>
    */
    Notify: function (msg, callback) {
        $.dialog({
            content: msg,
            icon: 'face-smile',
            ok: callback || null
        });
    },
    /*
    /// <summary>
    ///  模拟Confirm框
    /// </summary>
    /// <param name="msg">提示消息</param>
    /// <param name="ok">确定函数</param>
    /// <param name="cancel">取消函数</param>
    */
    Confirm: function (msg, ok, cancel) {
        $.dialog({
            content: msg,
            icon: 'question',
            ok: ok || true,
            cancel: cancel || true
        });
    },
    /*
    /// <summary>
    ///  以弹出层形式，弹出指定Url地址
    ///参数为json形式
    /// </summary>
    /// <param name="url">需显示的页面地址</param>
    /// <param name="title">弹出层title，默认为”操作“</param>
    /// <param name="data">需要传入指定Url的参数，跨域请求下无效</param>
    /// <param name="lock">是否需要遮罩层,默认为True</param>
    /// <param name="fixed">是否始终居中,默认为True</param>
    /// <param name="width">宽度，默认为auto</param>
    /// <param name="height">高度,默认为auto</param>
    */
    Open: function (para) {
        var lock = true, fixed = true;
        if (para.lock != undefined)
            lock = para.lock;
        if (para.fixed != undefined)
            fixed = para.fixed;
        if (para.data)
            $.dialog.data('data', para.data);
        $.dialog.open(para.url, { title: para.title || '操作', lock: lock, fixed: fixed
        , width: para.width || 'auto', height: para.height || 'auto'
        });
    }
};


/*AJAX公共JS方法*/
var Ajax = {
    Post: function (RequestUrl, params, successfunc, errorfunc) {
        //给参数加上时间戳，防止缓存
        params["RandomTime"] = new Date().getTime();
        $.ajax({
            url: RequestUrl,
            type: "POST",
            data: params,
            dataType: "json",
            success: successfunc,
            error: errorfunc || null
        });
    }
};